# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models


class WjInfo(models.Model):
    open_id = models.CharField(max_length=100, null=True, blank=True, default='')
    nickname = models.CharField(max_length=100, null=True, blank=True, default='')
    avatar = models.CharField(verbose_name='微信头像', max_length=2000, null=True, blank=True, default='')
    is_open = models.BooleanField(verbose_name='是否公开问卷', blank=True, default=False)
    wj_pass = models.CharField(verbose_name='问卷密码', max_length=100, null=True, blank=True, default='')

    cover = models.CharField(max_length=2000, null=True, blank=True, default='')
    title = models.TextField(max_length=2000, null=True, blank=True, default='')
    bref = models.TextField(max_length=2000, null=True, blank=True, default='')
    question_json = models.TextField(max_length=20000, null=True, blank=True, default='')

    like_wj_count = models.IntegerField(verbose_name='收藏用户数', null=True, blank=True, default=0)
    part_wj_count = models.IntegerField(verbose_name='参与用户数', null=True, blank=True, default=0)

    like_wj_json = models.TextField(verbose_name='收藏用户openid', max_length=20000, null=True, blank=True, default='')
    part_wj_json = models.TextField(verbose_name='参与用户openid', max_length=20000, null=True, blank=True, default='')

    create_date = models.DateTimeField(null=True, blank=True)
    update_date = models.DateTimeField(null=True, blank=True)
    expire_date = models.DateTimeField(null=True, blank=True)

    is_home = models.BooleanField(blank=True, default=False)
    enabled = models.BooleanField(blank=True, default=False)

    internal_search = models.CharField(max_length=50, null=True, blank=True, default='')

    class Meta:
        db_table = 'wj_info'
        verbose_name_plural = '问卷信息表'

    def __unicode__(self):
        return u"%s-%s-%s" % (self.open_id, self.nickname, self.id)


class WjUser(models.Model):
    open_id = models.CharField(max_length=100, null=True, blank=True, default='', unique=True)
    nickname = models.CharField(max_length=100, null=True, blank=True, default='')
    avatar = models.CharField(verbose_name='微信头像', max_length=2000, null=True, blank=True, default='')

    create_date = models.DateTimeField(null=True, blank=True)
    enabled = models.BooleanField(blank=True, default=False)

    class Meta:
        db_table = 'wj_user'
        verbose_name_plural = '问卷用户表'

    def __unicode__(self):
        return u"%s-%s-%s" % (self.open_id, self.nickname, self.id)


class WjBlock(models.Model):
    open_id = models.CharField(max_length=100, null=True, blank=True, default='', unique=True)
    create_date = models.DateTimeField(null=True, blank=True)

    class Meta:
        db_table = 'wj_block'
        verbose_name_plural = '问卷用户黑名单'

    def __unicode__(self):
        return u"%s-%s" % (self.open_id, self.id)
